package com.module.codeBind.dao;

import java.util.Iterator;
import java.util.List;

import org.hibernate.Session;

import base.dao.GenericHibernateDao;

import com.module.codeBind.vo.BindCodeApp;

public class BindCodeAppDao extends GenericHibernateDao<BindCodeApp,String>{

	private static BindCodeAppDao dao = new BindCodeAppDao();
	private BindCodeAppDao(){}
	public static BindCodeAppDao getInstance(){
		return dao;
	}
	public boolean save(Session session,List itemList,String bindId){
		this.deleteByQuery(session,"delete from BindCodeApp as obj where obj.bindId='"+bindId+"'");
		for(Iterator it = itemList.iterator();it.hasNext();){
			BindCodeApp bean = new BindCodeApp();
			bean.setCodeAppId((String)it.next());
			bean.setBindId(bindId);
			session.save(bean);
		}
		return true;
	}
	public List getListByBindId(Session session,String bindId){
		String hql = "select codeAppId from BindCodeApp as obj  where bindId ='"+bindId+"'";
		return session.createQuery(hql).list();
	}
}
